<template>
  <div id="app">
    <ele-header :seller="seller"></ele-header>
    <div class="tab">
      <div class="tab_item">
        <router-link to="/goods">商品</router-link>
      </div>
      <div class="tab_item">
        <router-link to="/ratings">评论</router-link>
      </div>
      <div class="tab_item">
        <router-link to="/seller">商家</router-link>
      </div>
    </div>
    <router-view :seller='seller'></router-view>
  </div>
</template>

<script>
import axios from 'axios'
import header from './components/header/header'

export default {
  name: 'App',
  data () {
    return {
      seller: {}
    }
  },
  components: {
    'ele-header': header
  },
  created () {
    /**
     * 页面初始化后从模拟数据请求数据给header渲染
     */
    setTimeout(() => {
      axios.get('/api/seller')
        .then(response => {
          const result = response.data
          if (result.code === 0) {
            this.seller = result.data
          }
        })
        .catch(error => {
          console.log(error)
        })
    }, 50)
  }
}

</script>
<style lang="stylus" rel="stylesheet/stylus">
@import 'common/stylus/mixins.styl';

.tab {
  height: 40px;
  line-height: 40px;
  display: flex;
  border_1px(rgba(7, 17, 27, 0.1));

  .tab_item {
    flex: 1;
    font-size: 14px;
    text-align: center;

    .active {
      color: red;
    }
  }
}
</style>
